﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity.ModelConfiguration;
using System.Data.Entity;

using Happy.Cms.Domain.Articles;

namespace Happy.Cms.Domain.EntityFramework.Articles
{
    public sealed class ArticleConfiguration : EntityTypeConfiguration<Article>
    {
        public ArticleConfiguration()
        {
            this.HasKey(x => x.Id);
            this.Property(x => x.OptimisticKey).IsRowVersion();
            this.HasMany(x => x.AssignedTags)
                .WithOptional()
                .Map(m =>
                {
                    m.MapKey("ArticleId");
                })
                .WillCascadeOnDelete();
        }
    }
}
